package com.wteam.dragon.model.pojo.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.*;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.wteam.dragon.system.basebean.bean.BaseBean;
import lombok.Data;

import java.util.Objects;
import java.util.Set;

/**
 * 角色
 * @Author 陈晓辉
 * @Date 2020/3/23
 */
@Data
@Table
@TableName
public class Role extends BaseBean{
    @IsKey
    @IsNotNull
    @IsAutoIncrement
    @TableId(type = IdType.AUTO)
    @ColumnType(MySqlTypeConstant.BIGINT)
    @Column(comment = "自增id")
    private Long id;

    @IsNotNull
    @ColumnType(MySqlTypeConstant.VARCHAR)
    @Column(comment = "角色名字")
    private String name;

    @ColumnType(MySqlTypeConstant.VARCHAR)
    @Column(comment = "角色的中文名字")
    private String nameZh;

    @IsNotNull
    @DefaultValue("本级")
    @ColumnType(MySqlTypeConstant.VARCHAR)
    @Column(comment = "数据权限类型 全部, 本级 , 自定义")
    private String dataScope;

    @IsNotNull
    @ColumnType(MySqlTypeConstant.INT)
    @Column(comment = "角色等级(1 最小)")
    private Integer level;

    @ColumnType(MySqlTypeConstant.VARCHAR)
    @Column(comment = "备注")
    private String remark;

    @ColumnType(MySqlTypeConstant.VARCHAR)
    @Column(comment = "权限")
    private String permission;

    @TableField(exist = false)
    private Set<Menu> menus;

    @TableField(exist = false)
    private Set<Long> deptIds;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Role role = (Role) o;
        return Objects.equals(id, role.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}

